#!/env/bin/env python3
'''
This file generates kinetic matrix. I.e. who hops where and with what strength.
'''


class Site:
    pass


class KineticMatrix:
    def __init__(self, **kwargs):
        self.dimension = kwargs['dimension']
        self.prim = kwargs['prim']
        self.orbit = kwargs['orbit']
        self.hamiltonian = kwargs['hamiltonian']
        self.super = kwargs['super']
        self.sitesInUnitCell = len(self.orb.orbits) #Number of sites in the unit cell

        self.nSites = self.sitesInUnitCell * self.super[0][0]

        self.Up = [[0] * self.nSites] * self.nSites
        self.Down = [[0] * self.nSites] * self.nSites
        if self.dimension == 1:
            self.lattice = [None] * self.nSites #Initialize lattice
            for orbit in self.orbit.orbits:
                for cellIndex in range(self.super[0][0]):

                    st = Site()
                    st.x = orbit.x + cellIndex * self.prim[0][0]
                    st.index = orbit.index

                    self.lattice[orbit.index + cellIndex] = st

            #fill Kinetic Matrix
            for site1, index1 in enumerate(self.lattice):
                for site2, index2 in enumerate(self.lattice):
                    if index1 == index2:
                        continue;

                    if abs(abs(self.hamiltonian.t[(site1.index, site2.index)].x) - (site1.x - site2.x)) < 1e-5:
                        self.Up[index1][index2] = self.hamiltonian.t[(site1.index, site2.index)].t_up
                        self.Down[index1][index2] = self.hamiltonian.t[(site1.index, site2.index)].t_down


